package com.blb.ssm.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.blb.ssm.dao.OrderMapper;
import com.blb.ssm.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService {
	
	@Autowired
	private OrderMapper orderMapper;

	@Transactional(rollbackFor=Exception.class)
	@Override
	public List<Map<String, Object>> getlist(String ostate, String otype,int page) throws Exception {
		int start=(page-1)*4;
		if(page==100)
		{
			return orderMapper.getlist(ostate,otype,100,4);
		}
		else {
			return orderMapper.getlist(ostate,otype,start,4);
		}
		
	}

	@Transactional(rollbackFor=Exception.class)
	@Override
	public int getCount(String ostate, String otype) throws Exception{
		return orderMapper.getCount(ostate,otype);
	}

	@Transactional(rollbackFor=Exception.class)
	@Override
	public void getDeleteOrder(String oid,String ostate,String otype) throws Exception{
		orderMapper.getDeleteOrder(oid,ostate,otype);
		orderMapper.getDeleteOrderGoods(oid);
	}

	@Transactional(rollbackFor=Exception.class)
	@Override
	public List<Map<String, Object>> getOnelist(String ostate, String otype, String oid) {
		return orderMapper.getOnelist(ostate,otype,oid);
	}
}
